using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

//适用于 一个按钮点击后需要打开orefab的场景
//挂在在按钮上即可
public class PrefabLoading : MonoBehaviour
{
    public GameObject Prefab;

    private Transform Canvas;
    void Start()
    {
        //获取按钮组件
        Button btn = GetComponent<Button>();
        //按钮点击监听
        btn.onClick.AddListener(InitPrefab);
        Canvas = GetComponentInParent<Canvas>().transform;
    }

    // Update is called once per frame
    void InitPrefab()
    {
        Instantiate(Prefab, Canvas);
    }
}
